<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">


    <ui:composition template="/WEB-INF/faces/template.xhtml">

        <!-- new title -->
        <ui:define name="title">
            Edit bookings
        </ui:define>

        <!-- new content -->
        <ui:define name="content">
            <!-- Check admin login -->
            <ui:include src="/resources/include/checkAdminLogin.xhtml" />

            <h:form>            
                <p:dataTable id="bookings" value="#{viewBookingsControllerBean.bookings}" var="booking">

                    <p:column sortBy="#{booking.user.name}" width="70">
                        <f:facet name="header">
                            <h:outputText value="User" style="width:70px" />
                        </f:facet>
                        <h:outputText value="#{booking.user.name}" style="width:70px">

                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{booking.bookDate}" width="70">
                        <f:facet name="header">
                            <h:outputText value="Booking date" style="width:70px" />
                        </f:facet>
                        <h:outputText value="#{booking.bookDate}" style="width:70px">
                            <f:convertDateTime type="date" pattern="yyyy-MM-dd"/>                       
                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{booking.startDate}" width="70">
                        <f:facet name="header">
                            <h:outputText value="Start date" style="width:70px"/>
                        </f:facet>
                        <h:outputText value="#{booking.startDate}" style="width:70px">
                            <f:convertDateTime type="date" pattern="yyyy-MM-dd"/>                       
                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{booking.endDate}" width="70" >
                        <f:facet name="header">
                            <h:outputText value="End date" style="width:70px" />
                        </f:facet>
                        <h:outputText value="#{booking.endDate}" style="width:70px">
                            <f:convertDateTime type="date" pattern="yyyy-MM-dd"/>                       
                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{booking.room.roomNb}" width="25" >
                        <f:facet name="header">
                            <h:outputText value="Room" style="width:25px" />
                        </f:facet>
                        <h:outputText value="#{booking.room.roomNb}" style="width: 25px"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Del" />
                        </f:facet>
                        <h:commandButton value="Del" action="#{viewBookingsControllerBean.del(booking.user, booking.startDate)}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Edit" />
                        </f:facet>
                        <h:commandButton value="Edit" action="#{viewBookingsControllerBean.saveValue(booking)}" />
                    </p:column>

                </p:dataTable>
            </h:form>
        </ui:define>        
    </ui:composition>
</html>

